<?php
/**
 * Orbital Payment Gateway
 *
 * @date: 2007-06-19
 * @by  : jessie@dwebsite.com
 * @version $Revision: 1.11.12.1 $
 *
 */

//require_once DWC_COMMON_DIR . '/xml.php';
Zend_Loader::loadClass("CommonXML");
define("ORBITAL_TEST_URL", 'https://orbitalvar1.paymentech.net');
define("ORBITAL_LIVE_URL", 'https://orbital1.paymentech.net');

class Orbital 
{
 	var $requestXml;

 	function Orbital($requestXml){
		$this->requestXml = $requestXml;
  	}

	function process(){

		$url = ORBITAL_LIVE_URL;

		$header  = "POST / AUTHORIZE HTTP/1.0 \r\n";
		$header .= "MIME-Version: 1.0 \r\n";
        $header .= "Content-type: application/PTI42 \r\n";
        $header .= "Content-length: ".strlen($this->requestXml)." \r\n";
        $header .= "Content-transfer-encoding: text \r\n";
        $header .= "Request-number: 1 \r\n";
        $header .= "Document-type: Request \r\n";
        $header .= "Interface-Version: Class Registration Program 1.8 \r\n";
        $header .= "Connection: close \r\n\r\n";
        $header .= $this->requestXml;

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
       	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_TIMEOUT, 360);
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $header);

        $this->responseXml = curl_exec($ch);
        if (curl_errno($ch)) {
        	print curl_error($ch);
        } else {
        	curl_close($ch);
        }

        $response = CommonXML::xml_parsexml($this->responseXml);
		return $response;
	}

}

?>